<?php

/* 
 * 日志表
 * @2015-12-29 wzl
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
class AdminLogModel extends db_help
{
    public $keyFields = 'log_id';//设置主键
    public function __construct() {
        parent::__construct();
        $this->table_name = $this->table('admin_log');
    }
    public static function load(){
        return new self();
    }
    public function add($content, $type, $user_id) {
        $ip = p_real_ip();
        $data = array(
            'user_id' => $user_id,
            'log_time' => time(),
            'log_type' => $type,
            'log_content' => $content,
            'log_ip' => $ip,
        );
        return $this->insert($data);
    }
    public function add_user($content){
        $type = '用户操作';
        return $this->add($content, $type);
    }

    /**
     * 获取信息
     * @param type $log_id
     * @return type
     */
    public function get_info($log_id) {
        return $this->getRow(null, array('log_id' => $log_id));
    }
    /**
     * 删除信息
     * @param type $log_id
     * @return type
     */
    public function del_info($log_id) {
        $where = array('log_id' => $log_id);
        return $this->delete($where);
    }
}

